package site.wenneng.dev.conf;

import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.ConnectionPool;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import java.util.Collections;
import java.util.concurrent.TimeUnit;

@Configuration
public class BeanConfig {

    @Bean
    public OkHttpClient okHttpClient() {
        return new OkHttpClient.Builder()
                .retryOnConnectionFailure(true)
                .connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
                .protocols(Collections.singletonList(Protocol.HTTP_1_1)).addInterceptor(new HeaderInterceptor()).build();
    }
}
